home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
NEWSOFT
/
AUGUST
/
ARCWEB
/
InetDB
/
Resolver
< prev
Wrap
Text File
|
1995-11-29
|
9KB
|
269 lines
INetDB - Cacheing Resolver
--------------------------
Copyright (c) 1994 Adam Goodfellow
This software is in part based upon source that is
Copyright (c) 1985, 1988 Regents of the University of California.
All rights reserved.
[NOTE: The InetDB module itself is no longer required by ArcWeb. However,
the configuration files used by ArcWeb are the same as those required by
InetDB, thus the instructions are the same]
Introduction
============
The basic Acorn and FreeNet TCP/IP stacks allows names of hosts with which
you want to communicate to be kept in a local file to save you having to
remember the numeric IP address for each host. For small networks this is
generally quite acceptable.
However, for larger networks and especially the Internet, keeping the
hosts file upto date can be very time consuming, if not impossible.
To get round this problem, it is normal for one or more machines on a
network to provide host name and IP address databases that are
accessable on a single machine.
In actual fact, with very large networks, this database (Domain Name
System or DNS) is distributed amongst a number of machines (called
name-servers), each being responsible for pursuing information about
other networks (domains) on behalf of hosts on its local network (in its
local domain), and answering secific queries about its local network
(domain) from systems on other networks (in other domains).
The Resolver provided as part of the INetDB module performs the task of
communicating with nameservers on behalf of many applications written
for the FreeNet and/or Acorn TCP/IP stacks.
Normally, as the name-server is a machine connected to your local
network, the time taken to get a reply from a nameserver is quite short,
a fraction of a second on a lightly loaded network and a lightly loaded
name-server.
However with heavily loaded networks and nameservers, or if the query
has to be sent over serial connection via a modem to a nameserver on the
Internet, the time taken for the response can be quite long, especially
with the recent upsurge in Internet use. Also, in circumstances of heavy
network conjestion, additional queries caused by resending of requests
that have been deemed lost further degrades network performance.
The obvious solution is to somehow reduce the dependancy upon the
name-server for processing queries every time you make a connection to
another named host.
This what sets this resolver apart from the types of resolver commonly
found on desktop computers. It remembers information recently obtained
from a name-server in a cache and so is often able to give an instant
responce to a repeat of recent similar query, making it very appropriate
for use where the nameserver is at the other end of a dial up connection
via a modem.
The cacheing methods used are such that so long as the name-servers are
providing accurate information about the life time of data retrieved,
then the cache will only give upto date information, and will
automatically remove information considered out of date, ensuring a
fresh copy is read from the nameserver.
Setting Up
==========
Resolver configuration is stored in the file "!FreeUser.Files.ResConf".
Options in this file are as follows: (See example)
nameserver
----------
nameserver <ip_address>
Internet address (in dot notation) of a name server that the resolver
should query.
Up to MAXNS (currently 3) name servers may be listed, one per keyword.
If there are multiple servers, the resolver library queries them in the
order listed. If no nameserver entries are present, the default is to
use the name server on the local machine. (The algorithm used is to try
a name server, and if the query times out, try the next, until out of
name servers, then repeat trying all the name servers until a maximum
number of retries are made).
domain
------
Local domain name.
Most queries for names within this domain can use short names relative
to the local domain.
If no domain entry is present, the domain is determined from the local
host name returned by gethostname() the domain part is taken to be
everything after the first '.'.
Finally, if the host name does not contain a domain part, the root
domain is assumed.
search
------
Search list for host-name lookup.
The search list is normally determined from the local domain name; by
default, it begins with the local domain name, then successive parent
domains that have at least two components in their names. This may be
changed by listing the desired domain search path following the
\fIsearch\fP keyword with spaces or tabs separating the names.
Most resolver queries will be attempted using each component of the
search path in turn until a match is found.
Note that this process may be slow and will generate a lot of network
traffic if the servers for the listed domains are not local, and that
queries will time out if no server is available for one of the domains.
The search list is currently limited to six domains
with a total of 256 characters.
sortlist
--------
Sortlist allows addresses returned by gethostbyname to be sorted.
A sortlist is specified by IP address netmask pairs. The netmask is
optional and defaults to the natural netmask of the net. The IP address
and optional network pairs are seperated by slashes. Up to 10 pairs may
be specified.
e.g. sortlist 130.155.160.0/255.255.240.0 130.155.0.0
options
-------
Options allows certain internal resolver variables to be modified.
The syntax is
options <option> ...
where <option> is one of the following:
debug sets RES_DEBUG in _res.options.
ndots sets a threshold for the number of dots which must appear in a
name given to res_query (see resolver) before an initial
absolute query will be made. The default for n is 1, meaning
that if there are any dots in a name, the name will be tried
first as an absolute name before any search list elements are
appended to it.
cachesize
---------
Enables the RR cache. Values may be given as <n> bytes, or <n>k kbytes.
Size less than 1024 are rounded upto 1024.
cacheload
---------
Read RRs from one or more file into the cache. If you are saving the
cache at shutdown, then one of thes files should be the cache file.
for eg:
cacheload resboot rescache
cachesave
---------
This sets where the cache is saved to at shutdown.
retry
-----
This sets the number of retries attempted to each nameserver (default 4)
timeout
-------
This sets the min and max timeouts between retrying the same nameserver again.
After each retry, the timeout is doubled upto the max value.
Nameserver retries are dstributed through the timeout period, so if the
timeout period is 6 seconds, and 3 nameservers have be specified, the
next nameserver is tried 2 seconds after the first.
----
The domain and search keywords are mutually exclusive. If more than one
instance of these keywords is present, the last instance wins.
The search keyword of a system's resolv.conf file can be overridden on a
per-process basis by setting the environment variable LOCALDOMAIN to a
space-separated list of search domains.
The options keyword of a system's resolv.conf file can be amended on a
per-process basis by setting the environment variable RES_OPTIONS to a
space-separated list of resolver options as explained above under
options.
The keyword and value must appear on a single line, and the keyword
(e.g. nameserver) must start the line. The value follows the keyword,
separated by white space.
Programmer Interface
====================
This file is incomplete, there are also a few *commands, some of which
are implemented.
The SWI Interface is as follows:
SWI Internet_GetHostByName &46000
On entry:
R0 = 0
R1 = -> host name
On exit:
R1 = pointer to hostent structure or NULL if not found
SWI Internet_GetHostByAddr &46001
On entry:
R0 = 0
R1 = -> host addr
R2 = len of addr
R3 = type of addr
On exit:
R1 = pointer to hostent structure, or NULL if not found
Where the hostent stucture is defined as below. Note that all addresses
are given in net byte order (the reverse of the normal Acorn byte order).
struct hostent {
char *h_name; /* Official name of host */
char **h_aliases; /* Alternative names for host */
int h_addrtype; /* Host address type */
int h_length; /* Length of each address */
char **h_addr_list; /* List of addresses for host */
#define h_addr h_addr_list[0] /* Address, for back compatability */
};